﻿using EPiServer.Web.PropertyControls;
using EPiServer.SpecializedProperties;
using EPiServer.Core;
using EPiServer.Web.PageExtensions;
using EPiServer.PlugIn;
using System;

namespace EPiServer.Labs.MobilePack.Site
{
    /// <summary>
    /// Property XHtmlString has a bug in it in CMS 6 R2 making it impossible to use in a dynamic content element without this fix 
    /// A hotfix is available from EPiServer Support making this property obsolete
    /// </summary>
    [Serializable, PageDefinitionTypePlugIn]
    public class PropertyXhtmlStringV2 : PropertyXhtmlString
    {
        public override IPropertyControl CreatePropertyControl()
        {
            return new PropertyXhtmlStringV2Control();
        }
    }

    public class PropertyXhtmlStringV2Control : PropertyXhtmlStringControl
    {
        public override void CreateEditControls()
        {
            (this.Page as PageBase).SavePageHandler = new SaveCurrentPage(this.Page as PageBase);
            base.CreateEditControls();
        }
    }
}